package com.solocredit.finance.ui.user.adapter

import android.annotation.SuppressLint
import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.solocredit.finance.R
import com.solocredit.finance.base.adapter.MullaRecyclerViewAdapter
import com.solocredit.finance.base.adapter.MullaViewHolderHelper
import org.json.JSONObject

/**
 * MullaFlow
 * @Author wwdeng
 * @CreateTime: 2024/8/12 17:07
 * @Annotation：用户积分明细列表
 */
class MullaUserPointsAdapter(recyclerView: RecyclerView?) : MullaRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_mulla_user_points) {

    override fun setItemChildListener(helper: MullaViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    @SuppressLint("SetTextI18n")
    override fun fillData(helper: MullaViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textType,model.optString("changeInfo"))

        val textPoint = helper.getTextView(R.id.textPoint)
        val changeScore = model.optInt("changeScore")
        if (changeScore > 0){
            textPoint.text = "+ $changeScore"
            textPoint.setTextColor(Color.parseColor("#FF000000"))
        } else {
            textPoint.text = "$changeScore"
            textPoint.setTextColor(Color.parseColor("#FFFFAC25"))
        }
    }
}